import { type RequestHandler } from '@builder.io/qwik-city';
import { type PlatformCloudflarePages } from '@builder.io/qwik-city/middleware/cloudflare-pages';
import { login } from '~/drivers';

export const onPost: RequestHandler<PlatformCloudflarePages> = async ({ json, platform, parseBody }) => {
  const body = await parseBody();
  const res = await login((platform.env as Env)['KVDATA'], body);
  json(200, res);
};
